<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 头部操作栏 -->
            <div class="layui-form lay-header" id="exportFrom">
                <div class="toolbar">
                    <div class="layui-form-item lay-query-content">
                        <div class="lay-query-box">
                            <div class="query-lt">
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">领用记录编号：</label>
                                    <div class="layui-input-inline">
                                        <input name="code" class="layui-input" type="text" placeholder="请输入领用订单编号"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">称重柜编号：</label>
                                    <div class="layui-input-inline">
                                        <select  name="cabCode" lay-filter="cabCode"  lay-search lay-verify="">
                                            <option value="">请选称重柜</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">物料编号：</label>
                                    <div class="layui-input-inline">
                                        <input name="skuCode" class="layui-input" type="text" placeholder="请输入物料编号"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">领取日期:</label>
                                    <div class="layui-input-inline">
                                        <input name="createTime" id="pTime" class="layui-input date-icon" type="text"
                                               placeholder="选择时间" autocomplete="off" style="width: 200px" readonly/>
                                    </div>
                                    <input name="startTime" id="startTime" type="hidden"/>
                                    <input name="endTime" id="endTime" type="hidden"/>
                                </div>
                            </div>
                            <div class="query-rt">
                                <div class="layui-inline">
                                    <button class="layui-btn icon-btn color-green" lay-filter="formSubSearchLog" lay-submit>查询</button>
                                    <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>重置</button>
                                    <button id="cellInventoryOutExport" class="layui-btn icon-btn"><i class="layui-icon">&#xe67d;</i>导出</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!--
                <div class="lay-btn-rows">
                    <div class="lay-btn-box">
                        <div class="lay-btn-lt">

                            <button id="wcabCellInventoryOutBtnAdd" class="layui-btn icon-btn color-reseda">添加领新记录</button>

                        </div>
                        <div class="lay-btn-rt">
                        </div>
                    </div>
                </div>
                -->
            </div>
            <!-- 表格 -->
            <table class="layui-table" id="wcabCellInventoryOutTable" lay-filter="wcabCellInventoryOutTable"></table>
        </div>
    </div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="wcabCellInventoryOutTableBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">详情</a>
    <!--
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    -->
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="storageInventoryInoutForm">
    <form lay-filter="storageInventoryInoutForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <div class="layui-form-item">
            <label class="layui-form-label">创建者</label>
            <div class="layui-input-block">
                <input name="creator" placeholder="请输入创建者" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">修改者</label>
            <div class="layui-input-block">
                <input name="modifier" placeholder="请输入修改者" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">创建人</label>
            <div class="layui-input-block">
                <input name="creatorName" placeholder="请输入创建人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">修改人</label>
            <div class="layui-input-block">
                <input name="modifierName" placeholder="请输入修改人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">存刀任务编号</label>
            <div class="layui-input-block">
                <input name="code" placeholder="请输入存刀任务编号" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">no</label>
            <div class="layui-input-block">
                <input name="no" placeholder="请输入no" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">day</label>
            <div class="layui-input-block">
                <input name="day" placeholder="请输入day" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">操作类型</label>
            <div class="layui-input-block">
                <select name="operationType">
                        <option value="in">存刀</option>
                        <option value="out">取刀</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">业务类型</label>
            <div class="layui-input-block">
                <select name="businessType">
                        <option value="temp">暂存</option>
                        <option value="repair">报修</option>
                        <option value="recycle">回收</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <select name="status">
                        <option value="created">已创建/待盘验</option>
                        <option value="checked">已盘验</option>
                        <option value="notified">已通知/回收中</option>
                        <option value="taked">平台已取货/已回收</option>
                        <option value="signed">已签收/已完成</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">盘验人id</label>
            <div class="layui-input-block">
                <input name="checkUserId" placeholder="请输入盘验人id" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">盘验人</label>
            <div class="layui-input-block">
                <input name="checkUserName" placeholder="请输入盘验人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">通知人</label>
            <div class="layui-input-block">
                <input name="notifyUserId" placeholder="请输入通知人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">通知人</label>
            <div class="layui-input-block">
                <input name="notifyUserName" placeholder="请输入通知人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">回收人id</label>
            <div class="layui-input-block">
                <input name="takeUserId" placeholder="请输入回收人id" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">回收人</label>
            <div class="layui-input-block">
                <input name="takeUserName" placeholder="请输入回收人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="storageInventoryInoutFormSubmit" lay-submit>保存</button>
        </div>
    </form>
</script>

<script type="text/html" id="detailTable">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->

                <!-- 表格 -->
                <table class="layui-table" id="inoutTable" lay-filter="inoutTable"></table>
                <br>
                <table class="layui-table" id="inoutDetailTable" lay-filter="inoutDetailTable"></table>
            </div>
        </div>
    </div>
</script>


<script type="text/html" id="wcabCellInventoryOutForm">
    <form lay-filter="wcabCellInventoryOutForm" class="layui-form model-form">
        <input name="id" type="hidden"/>




        <div class="layui-form-item">
            <label class="layui-form-label">称重柜</label>
            <div class="layui-input-block">
                <select name="cabId" id="cabId4simpleBatchUnload" lay-filter="cabId" lay-verify="required" lay-search required ></select>
            </div>
        </div>

        <!--
        <div class="layui-form-item">
            <label class="layui-form-label">货道</label>
            <div class="layui-input-block">
                <select name="spaceId" id="spaceId4simpleBatchUnload" lay-filter="spaceId" lay-verify="required" lay-search required></select>
            </div>
        </div>



        <div class="layui-form-item">
            <label class="layui-form-label">下货数量</label>
            <div class="layui-input-block">
                <input name="quantity" placeholder="请输入下货数量" type="text" class="layui-input" lay-verify="required|number|verifyQuantity" required/>
            </div>
        </div>
        -->

        <div class="layui-form-item">
            <label class="layui-form-label">领货明细</label>
            <div class="layui-input-block">
                <table class="layui-table" id="cabLaneUnloadTable" lay-filter="cabLaneUnloadTable"></table>
            </div>
        </div>

        <div class="layui-form-item" id="wcabCellInventoryOutBtnAddDetailDiv">
            <label class="layui-form-label"></label>
            <div class="layui-input-inline">
                <button id="wcabCellInventoryOutBtnAddDetail" class="layui-btn" lay-filter="wcabCellInventoryOutBtnAddDetail" onclick="return false;">增加领新明细</button>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <input name="remark" placeholder="请输入备注" type="text" class="layui-input" lay-verify="" required/>
            </div>
        </div>



        <div class="layui-form-item text-right saveBatchUnloadSimpleBtn">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="wcabCellInventoryOutFormSubmit" lay-submit>提交</button>
        </div>
    </form>
</script>

<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'admin', 'laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;
        var laydate = layui.laydate;

        // 渲染表格
        var insTb = table.render({
            elem: '#wcabCellInventoryOutTable',
            url: config.base + 'enterprisecab/wcabinet/admin/wcabCellInventoryOut/list',
            page: true,
            cellMinWidth: 100,
            cols: [[
                {type: 'numbers'}

                ,{field: 'code', sort: true, title: '领用记录编号'}
                ,{field: 'cabCode', sort: true, title: '柜子编号'}
                ,{field: 'spaceCode', sort: true, title: '货位编号'}
                ,{field: 'skuName', sort: true, title: '物料名称'}
                ,{field: 'skuCode', sort: true, title: '物料编号'}
                ,{field: 'skuSpecOld', sort: true, title: '规格编号'}
                // ,{field: 'deviceCode', sort: true, title: '机台'}
                ,{field: 'weight', sort: true, title: '重量',templet:function (d) {
                        if(d.weight<0){
                            return d.weight*-1;
                        }
                        return d.weight;
                    }}
                ,{field: 'weightUnitDesc', sort: true, title: '重量单位'}
                ,{field: 'quantity', sort: true, title: '数量',templet:function (d) {
                        if(d.quantity<0){
                            return d.quantity*-1;
                        }
                        return d.quantity;
                    }}
                ,{field: 'quantityUnitDesc', sort: true, title: '数量单位'}
                ,{field: 'creatorName', sort: true, title: '领取人'}
                ,{field: 'createTime', sort: true, title: '领取时间'}

                // ,{field: 'no', sort: true, title: 'no'}
                // ,{field: 'day', sort: true, title: 'day'}
                // ,{field: 'operationTypeDesc', sort: true, title: '操作类型'}
                // ,{field: 'businessTypeDesc', sort: true, title: '业务类型'}
                // ,{field: 'statusDesc', sort: true, title: '状态'}
                // ,{field: 'checkTime', sort: true, title: '盘验时间'}
                // ,{field: 'checkUserId', sort: true, title: '盘验人id'}
                // ,{field: 'checkUserName', sort: true, title: '盘验人'}
                // ,{field: 'notifyTime', sort: true, title: '通知时间'}
                // ,{field: 'notifyUserId', sort: true, title: '通知人'}
                // ,{field: 'notifyUserName', sort: true, title: '通知人'}
                // ,{field: 'takeUserId', sort: true, title: '回收人id'}
                // ,{field: 'takeUserName', sort: true, title: '回收人'}
                // ,{field: 'takeTime', sort: true, title: '回收时间'}
                // ,{field: 'inoutId', sort: true, title: '暂存柜存刀id'}
                // ,{field: 'cabId', sort: true, title: '柜子id'}
                // ,{field: 'skuId', sort: true, title: 'sku id'}
                // ,{field: 'companyId', sort: true, title: '企业id'}
                // ,{field: 'spaceId', sort: true, title: '货道id'}
                // ,{field: 'operationTypeDesc', sort: true, title: '操作类型'}
                // ,{field: 'businessTypeDesc', sort: true, title: '业务类型'}
                // ,{field: 'quantityCurrent', sort: true, title: '当前库存'}
                // ,{field: 'quantityAfter', sort: true, title: '变动后库存'}

                ,{align: 'center', toolbar: '#wcabCellInventoryOutTableBar', title: '操作', width: 80}
            ]],
            done: function (res, curr, count) {
                //移除按钮
                var menuButton = config.getMenuButton(location.hash);
                if(menuButton.indexOf("搜索") == -1){
                    $('.layui-form.toolbar').remove();
                }
                if(menuButton.indexOf("修改") == -1){
                    $("[lay-event='edit']").remove();
                }
                if(menuButton.indexOf("删除") == -1){
                    $("[lay-event='del']").remove();
                }
            }
        });

        // 工具条点击事件
        table.on('tool(wcabCellInventoryOutTable)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') { //修改
                showEditModel(data);
            } else if (obj.event === 'del') { // 删除
                doDelete(obj);
            }else if(obj.event=='detail'){
                showDetailModel(data)
            }
        });

        //监听排序
        table.on('sort(wcabCellInventoryOutTable)', function(obj){
            table.reload('wcabCellInventoryOutTable', {
                initSort: obj
                ,where: {
                    sort: obj.field
                    ,order: obj.type
                }
            });
        });

        // 搜索
        form.on('submit(formSubSearchLog)', function (data) {
            insTb.reload({where: data.field,page: {curr: 1}},'data');
        });
// 重置搜索
        form.on('submit(resets)', function (data) {
            $(".lay-header").find('select').val("");
            $(".lay-header").find('input').val("");
            let field = data.field;
            for (let key in field) {
                field[key] = ''
            }
            insTb.reload({where: field, page: {curr: 1}}, 'data');
        });
        $('#wcabCellInventoryOutBtnAdd').click(function () {
            showEditOutModel();
        });

        admin.req('enterprisecab/cabinet/admin/cabinet/list', {limit:999,cabinetNature:'sale',cabinetType:'gravity'}, function (res) {
            if (200 == res.code) {
                var optionHtml='<option value=""> 请选择称重柜</option>';
                for(var k=0;k<res.data.length;k++){
                    optionHtml+='<option value="'+res.data[k].code+'">'+res.data[k].code+'</option>';
                }
                $("select[name='cabCode']").html(optionHtml);
                form.render('select')
            } else {
                layer.msg(res.msg, {icon: 2, time: 1000});
            }
        }, 'GET');

        form.render('select');

        // 添加按钮点击事件
        $('#storageInventoryInoutBtnAdd').click(function () {
            showEditModel();
        });

        function showEditOutModel(data) {
            var title='添加领新订单';
            if(data){
                title='领新订单详情'
            }
            admin.open({
                type: 1,
                area: '1700px',
                offset: '65px',
                title: title,
                content: $('#wcabCellInventoryOutForm').html(),
                success: function () {
                    if (data){
                        var option = $("form select[name='type']").find("option");
                        layui.each(option, function(index, item){
                            if(data.type  == item.text){
                                data.type = item.value;
                            }
                        });
                    }


                    var getCabSpace=function(cabinetId,skuCode,selectDomNo){
                        // var cabLaneHtml='';
                        var queryFlag='unloadSimple';
                        if(data&&data.eventType=='detail'){
                            queryFlag='unloadSimple4Detail';
                        }
                        admin.req('enterprisecab/cabinet/admin/cabinetCargoLane/list', {cabinetId:cabinetId,skuCode:skuCode,limit:999,queryFlag:queryFlag,wsFlag:'gravity',businessType:'normal'}, function (res) {

                            if (res.code == 200) {
                                var html='<option value="">请选择货道</option>'
                                for(var k=0;k<res.data.length;k++){
                                    // html+='<option value="'+res.data[k].id+'" data-cabcode="'+res.data[k].cabCode+'" data-spacecode="'+res.data[k].code+'" data-skucode="'+res.data[k].skuCode+'" data-skuname="'+res.data[k].skuName+'" data-skuid="'+res.data[k].skuId+'" data-storagecapacity="'+res.data[k].storageCapacity+'" data-currentstock="'+res.data[k].currentStockCount+'" data-currentweight="'+res.data[k].currentWeight+'" data-speccode="'+res.data[k].skuSpecOld+'" data-unit="'+res.data[k].unitName+'" data-weightunit="'+res.data[k].skuWeightUnit+'">'+'货道编号:'+res.data[k].code+'|物料编号:'+res.data[k].skuCode+'|SKU名称:'+res.data[k].skuName+'|SKU规格:'+res.data[k].skuSpecOld+'</option>'
                                    html+='<option value="'+res.data[k].id+'" data-cabcode="'+res.data[k].cabCode+'" data-spacecode="'+res.data[k].code+'" data-skucode="'+res.data[k].skuCode+'" data-skuname="'+res.data[k].skuName+'" data-skuid="'+res.data[k].skuId+'" data-storagecapacity="'+res.data[k].storageCapacity+'" data-currentstock="'+res.data[k].currentStockCount+'" data-currentweight="'+res.data[k].currentWeight+'" data-speccode="'+res.data[k].skuSpecOld+'" data-unit="'+res.data[k].unitName+'" data-weightunit="'+res.data[k].skuWeightUnit+'">'+'货道编号:'+res.data[k].code+'</option>'
                                }
                                // cabLaneHtml=html;
                                $("#cabLaneId"+selectDomNo).html(html);
                                form.render('select')

                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'GEt',false);
                    }


                    admin.req('enterprisecab/cabinet/admin/cabinet/list', {cabinetNature:'sale',cabinetType:'gravity',limit:999}, function (res) {

                        if (res.code == 200) {
                            var html='<option value="">请选择称重柜</option>'
                            for(var k=0;k<res.data.length;k++){
                                html+='<option value="'+res.data[k].code+'" data-cabid="'+res.data[k].id+'" data-cabcode="'+res.data[k].code+'">'+res.data[k].code+'</option>'
                            }
                            $("#cabId4simpleBatchUnload").html(html);
                            form.render('select');
                            if(data){
                                $("#cabId4simpleBatchUnload").val(data.cabCode);
                                form.render('select');
                                // getCabSpace(data.cabId);
                            }
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }, 'GEt',false);




                    form.on('select(cabId)',function(selectData){

                        if(selectData.value!=''){
                            var cabId=$("#cabId4simpleBatchUnload option:selected").data('cabid');
                            var cabCode=$("#cabId4simpleBatchUnload option:selected").data('cabcode');
                            // getCabSpace(cabId);
                            getProduct(cabCode)
                            $("form select[name='cabLaneId']").each(function(index,item){
                                var id=item.id;

                                var eleNo=id.substring('cabLaneId'.length,id.length);
                                // var skuId=$(this).val();
                                // var skuCode=$(this).find('option:selected').data('skucode');
                                // var cabLaneId=$("#cabLaneId"+eleNo).val();
                                $("#skuId4BatchLoad"+eleNo).html(productHtml);
                                var skuCode=$("#skuId4BatchLoad"+eleNo+" option:selected").data('skucode')
                                if (skuCode){
                                    // getCabSpace(cabId,skuCode,eleNo);
                                }
                                // $("#cabLaneId"+eleNo).html(cabLaneHtml);
                                $("#quantity"+eleNo).attr('placeholder','请输入数量');
                                form.render('select');

                            })
                        }
                    })
                    var productHtml='';
                    var getProduct=function(cabCode){
                        // var receiveId=$("#receiveId").val();
                        productHtml='';
                        admin.req('enterprise/product/admin/productDetail/list', {limit:999,isDeleted:0,queryFlag:'wcabUnload',cabCode:cabCode}, function (res) {

                            if (res.code == 200) {
                                var html='<option value="">请选择物料</option>'
                                for(var k=0;k<res.data.length;k++){
                                    html+='<option value="'+res.data[k].skuCode+'" data-skuid="'+res.data[k].id+'" data-skucode="'+res.data[k].skuCode+'" data-skuname="'+res.data[k].skuName+'" data-speccode="'+res.data[k].oldSpecCode+'" data-unit="'+res.data[k].unitName+'" data-weightunit="'+res.data[k].weightNumber+'">'+'物料编号:'+res.data[k].skuCode+'|物料名称:'+res.data[k].skuName+'|规格:'+res.data[k].oldSpecCode+'</option>'
                                }
                                productHtml=html;
                                // $("#skuId4simple").html(html);
                                // form.render('select');
                                if(data){
                                    // $("#skuId4simple").val(data.skuId);
                                    // form.render('select');
                                    // getCabSpace(data.cabId,data.skuCode);
                                }
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'GEt',false);
                    }

                    getProduct();




                    var j=0;





                    var tHeaderHtml='<thead id="cabLaneUnloadHead">' +
                        '<tr>' +
                        '<th>序号</th>' +
                        '<th style="30%">物料</th>' +
                        '<th>货道</th>' +
                        '<th style="">物料名称</th>' +
                        '<th style="">物料编号</th>' +
                        '<th style="">规格</th>' +
                        '<th style="">单位</th>' +
                        '<th style="">单位重量</th>' +
                        '<th style="" id="currentStockTh">当前库存</th>' +
                        '<th style="">领新数量</th>' +
                        '<th style="">领新重量</th>' +
                        '<th style="">备注</th>' ;
                    if(data==undefined||(data&&data.eventType!='audit'&&data.eventType!='detail')){
                        tHeaderHtml+='<th><div align="center">操作</div></th>' ;
                    }

                    tHeaderHtml+='</tr>' +
                        '</thead>';
                    var html=tHeaderHtml+"<tbody id='cabLaneUnloadTbody'></tbody>";
                    $("#cabLaneUnloadTable").html(html);
                    form.render();

                    var getProductHtml=function(j){
                        var html='<select id="skuId4BatchLoad'+j+'"  name="skuId4BatchLoad" lay-filter="skuId4BatchLoad'+j+'" lay-verify="required" lay-search >' +
                            productHtml+
                            '</select>' ;
                        return html;
                    }

                    var getCabLaneHtml=function(j){
                        var html= '                <select id="cabLaneId'+j+'"  name="cabLaneId" lay-filter="cabLaneId'+j+'"  lay-verify="required" lay-search >\n' +
                            // cabLaneHtml+
                            '                </select>\n' ;
                        return html;
                    }


                    var getQuantityHtml=function(j){
                        var html='<input id="quantity'+j+'" name="quantity" placeholder="请输入数量" type="text" class="layui-input" lay-verify="required|number" required/>' ;
                        return html;
                    }

                    var getWeightHtml=function(j){
                        var html='<input id="weight'+j+'" name="weight" placeholder="请输入重量" type="text" class="layui-input" lay-verify="required" required/>' ;
                        return html;
                    }

                    var getRemarkHtml=function(j){
                        var html='<input id="remark'+j+'" name="remark" placeholder="请输入备注" type="text" class="layui-input" lay-verify="" required/>' ;
                        return html;
                    }

                    var addTableTr=function(resultData){

                        var tBodyHtml='<tr class="layui-form cabLaneTr" id="cabLaneTr'+j+'">' +
                            '<td>'+(j+1)+'</td>' +
                            '<td style="" id="skuId4BatchLoadTd'+j+'" class="skuId4BatchLoadTd">'+getProductHtml(j)+'</td>' +
                            '<td style="table-layout: fixed" id="cabLaneTd'+j+'">'+getCabLaneHtml(j)+'</td>' +
                            // '<td style="" id="skuTd'+j+'"></td>' +
                            '<td style="" id="skuNameTd'+j+'"></td>' +
                            '<td style="" id="skuCodeTd'+j+'"></td>' +
                            '<td style="" id="skuSpecTd'+j+'"></td>' +
                            '<td style="" id="skuUnitTd'+j+'"></td>' +
                            '<td style="" id="skuWeightUnitTd'+j+'"></td>' +

                            '<td style="" id="currentWeightTd'+j+'"></td>' +
                            '<td id="quantityTd'+j+'">'+getQuantityHtml(j)+'</td>'+
                            '<td id="weightTd'+j+'">'+getWeightHtml(j)+'</td>'+
                            '<td id="remarkTd'+j+'">'+getRemarkHtml(j)+'</td>';
                        if(data==undefined||(data&&data.eventType!='audit'&&data.eventType!='detail')){
                            tBodyHtml+='<td style="width: 50px;table-layout: fixed" class="layui-table-cell"  align="center">' +
                                '<button id="delBtn' + j + '" class="layui-btn layui-btn-xs delBtn" type="button" lay-filter="delBtn' + j + '"  formnovalidate>删除</button>'+
                                '</td>';
                        }

                        tBodyHtml+='</tr>' ;

                        var $tr=$("#cabLaneUnloadTbody tr")
                        if($tr.length==0){
                            $("#cabLaneUnloadTbody").html(tBodyHtml);
                        }else{
                            $($tr[$tr.length-1]).after(tBodyHtml)
                            // $tr[$tr.length-1].after(tBodyHtml);
                            form.render();
                        }
                        form.render();


                        $("#quantity"+j).on('input',function(){
                            var parentDom=$(this);
                            var domId=parentDom[0].id;
                            var selectDomNo=domId.substring("quantity".length,domId.length);
                            var skuWeight=$("#cabLaneId"+selectDomNo+" option:selected").data('weightunit');

                            var currentQuantity=$("#cabLaneId"+selectDomNo+" option:selected").data('currentstock');
                            var currentWeight=$("#cabLaneId"+selectDomNo+" option:selected").data('currentweight');
                            var quantity=$(this).val();
                            if(skuWeight&&quantity){
                                if(parseInt(currentQuantity)!=parseInt(quantity)) {
                                    var weight = parseInt(quantity) * parseFloat(skuWeight);
                                    $("#weight" + selectDomNo).val(weight);
                                }else{
                                    $("#weight" + selectDomNo).val(parseFloat(currentWeight));
                                }


                            }


                        })

                        $("#weight"+j).on('input',function(){
                            var parentDom=$(this);
                            var domId=parentDom[0].id;
                            var selectDomNo=domId.substring("weight".length,domId.length);
                            var skuWeight=$("#cabLaneId"+selectDomNo+" option:selected").data('weightunit');
                            var currentWeight=$("#cabLaneId"+selectDomNo+" option:selected").data('currentweight');
                            var currentQuantity=$("#cabLaneId"+selectDomNo+" option:selected").data('currentstock');
                            var weight=$(this).val();
                            if(skuWeight&&weight){
                                if(parseFloat(weight)!=parseFloat(currentWeight)){
                                    var quantity=parseFloat(weight)/parseFloat(skuWeight);
                                    quantity=parseInt(quantity);
                                    $("#quantity"+selectDomNo).val(quantity);
                                }else{
                                    $("#quantity"+selectDomNo).val(currentQuantity);
                                }

                            }

                        })

                        form.on('select(skuId4BatchLoad'+j+')',function(selectData){
                            var selectDom=$(this);
                            var parentDom=selectDom.parent().parent().parent();
                            var selectHtml=parentDom[0].innerHTML;
                            var startIndex=selectHtml.indexOf('skuId4BatchLoad',0);
                            var endIndex=selectHtml.indexOf('"',startIndex);
                            var selectDomNo=selectHtml.substring(startIndex,endIndex);
                            var selectDomNo=selectDomNo.substring("skuId4BatchLoad".length,selectDomNo.length);
                            if(selectData.value!=''){

                                var skuCode=$("#skuId4BatchLoad"+selectDomNo+" option:selected").data("skucode");
                                var skuName=$("#skuId4BatchLoad"+selectDomNo+" option:selected").data("skuname");
                                var oldSpecCode=$("#skuId4BatchLoad"+selectDomNo+" option:selected").data("speccode");
                                var unitName=$("#skuId4BatchLoad"+selectDomNo+" option:selected").data("unit");
                                var weightunit=$("#skuId4BatchLoad"+selectDomNo+" option:selected").data("weightunit")


                                $("#skuNameTd"+selectDomNo).html(skuName);
                                $("#skuCodeTd"+selectDomNo).html(skuCode);
                                $("#skuSpecTd"+selectDomNo).html(oldSpecCode);
                                $("#skuUnitTd"+selectDomNo).html(unitName);
                                $("#skuWeightUnitTd"+selectDomNo).html(weightunit);
                                form.render('select')
                                var skuCode=$("#skuId4BatchLoad"+selectDomNo+" option:selected").data("skucode");

                                $("#cabLaneTd"+selectDomNo).html(getCabLaneHtml(selectDomNo));

                                // $("#quantityTd"+selectDomNo).html('')
                                form.render('select');
                                var obj=$(this).find('option:selected');
                                // var skuCode=$(this).find('option:selected').data('skucode')
                                // var skuCode=$(this).find('option:selected').data('skucode');
                                var skuCode=$("#skuId4BatchLoad"+selectDomNo+" option:selected").data('skucode')
                                var cabId=$("#cabId4simpleBatchUnload option:selected").data('cabid');
                                if(cabId){
                                    getCabSpace(cabId,skuCode,selectDomNo);
                                }



                            }

                        })

                        form.on('select(cabLaneId'+j+')',function(data){
                            if(data.value!=''){
                                var selectDom=$(this);
                                var parentDom=selectDom.parent().parent().parent();
                                var selectHtml=parentDom[0].innerHTML;
                                var startIndex=selectHtml.indexOf('cabLaneId',0);
                                var endIndex=selectHtml.indexOf('"',startIndex);
                                var selectDomNo=selectHtml.substring(startIndex,endIndex);
                                var selectDomNo=selectDomNo.substring("cabLaneId".length,selectDomNo.length);
                                var currentQuantity=$("#cabLaneId"+selectDomNo+" option:selected").data('currentstock')
                                $("#quantity"+selectDomNo).attr('placeholder','最大可下货数量：'+currentQuantity);
                                // var capacity=$("#cabLaneId"+selectDomNo+" option:selected").data('storagecapacity')
                                // $("form input[name='quantity']").attr('placeholder','货道最大可下货数量：'+capacity);
                                var skuCode=$("#cabLaneId"+selectDomNo+" option:selected").data("skucode");
                                var skuName=$("#cabLaneId"+selectDomNo+" option:selected").data("skuname");
                                var oldSpecCode=$("#cabLaneId"+selectDomNo+" option:selected").data("speccode");
                                var unitName=$("#cabLaneId"+selectDomNo+" option:selected").data("unit");
                                var weightUnit=$("#cabLaneId"+selectDomNo+" option:selected").data("weightunit")
                                var currentWeight=$("#cabLaneId"+selectDomNo+" option:selected").data("currentweight")
                                $("#weight"+selectDomNo).attr('placeholder','最大可下货重量：'+currentWeight);
                                // $("#skuNameTd"+selectDomNo).html(skuName);
                                // $("#skuCodeTd"+selectDomNo).html(skuCode);
                                // $("#skuSpecTd"+selectDomNo).html(oldSpecCode);
                                // $("#skuUnitTd"+selectDomNo).html(unitName);
                                // $("#skuWeightUnitTd"+selectDomNo).html(weightUnit);

                                $("#currentWeightTd"+selectDomNo).html('重量:'+currentWeight+';数量:'+currentQuantity);
                                var quantity=$("#quantity"+selectDomNo).val();
                                if(quantity){
                                    var weight = parseInt(quantity) * parseFloat(weightUnit);
                                    $("#weight" + selectDomNo).val(weight);
                                }

                            }
                        })

                        j++;
                        $(".delBtn").off('click').on('click',function(data){
                            var btn=$(this);
                            var btnId=btn[0].id;
                            var btnNo=btnId.substring("delBtn".length,btnId.length);

                            layer.confirm('确定要删除吗？', {
                                offset: '65px',
                                skin: 'layui-layer-admin'
                            }, function (i) {
                                layer.close(i);
                                btn.parent().parent().remove()
                                // layer.load(2);

                            });
                        })

                    }

                    var getLoadDetail=function(){
                        var laneHtml='';
                        admin.req('enterprisecab/cabinet/admin/cabinetCargoLane/list', {cabCode4Query:data.cabCode,limit:999}, function (res) {
                            if ( res.code==200) {
                                var html='<option value="">请选择货道</option>'
                                for(var k=0;k<res.data.length;k++){
                                    html+='<option value="'+res.data[k].code+'" data-laneid="'+res.data[k].id+'" data-cabcode="'+res.data[k].cabCode+'" data-skucode="'+res.data[k].skuCode+'" data-skuid="'+res.data[k].skuId+'" data-storagecapacity="'+res.data[k].storageCapacity+'" data-weightcapacity="'+res.data[k].weightCapacity+'" data-currentstock="'+res.data[k].quantityInventory+'" data-currentweight="'+res.data[k].currentWeight+'">'+res.data[k].code+'</option>'
                                }
                                laneHtml=html;
                            } else {
                                layer.msg('获取货道失败', {icon: 2, time: 1000});
                            }
                        }, 'GET',false);
                        admin.req('enterprisecab/wcabinet/admin/wcabCellLoadDetail/list', {loadId:data.id,limit:9999}, function (res) {
                            console.log(data);
                            if (res.code==200) {
                                $("#currentStockTh").hide();
                                for(let k=0;k<res.data.length;k++){
                                    addTableTr();
                                    var selectDomNo=j-1;
                                    var skuId=res.data[k].skuId;
                                    var skuCode=res.data[k].skuCode;
                                    var spaceId=res.data[k].spaceId;
                                    var quantity=res.data[k].quantity;
                                    var weight=res.data[k].weight;
                                    var remark=res.data[k].remark;
                                    var spaceCode=res.data[k].spaceCode;
                                    var oldSpecCode=res.data[k].skuSpecOld
                                    var unitName=res.data[k].unitName;
                                    var skuWeightUnit=res.data[k].skuWeightUnit;
                                    var skuName=res.data[k].skuName;

                                    $("#skuCodeTd"+selectDomNo).html(skuCode);
                                    $("#skuNameTd"+selectDomNo).html(skuName);
                                    $("#skuSpecTd"+selectDomNo).html(oldSpecCode);
                                    $("#skuUnitTd"+selectDomNo).html(unitName);
                                    $("#skuWeightUnitTd"+selectDomNo).html(skuWeightUnit);
                                    $("#quantity"+selectDomNo).val(quantity);
                                    $("#weight"+selectDomNo).val(weight);
                                    $("#remark"+selectDomNo).val(remark);
                                    $("#cabLaneTd"+selectDomNo).html(getCabLaneHtml(selectDomNo));
                                    form.render('select')
                                    $("#cabLaneId"+selectDomNo).html(laneHtml);
                                    form.render('select')
                                    $("#cabLaneId"+selectDomNo).val(spaceCode);
                                    form.render('select')
                                    $("#cabLaneTr"+selectDomNo).find("*").attr('disabled','disabled');
                                    form.render();
                                    $("#currentWeightTd"+selectDomNo).hide();

                                }
                                if(data&&(data.eventType=='audit'||data.eventType=='detail')){
                                    $("#cabLaneTbody").find("*").attr('disabled','disabled');
                                }
                            } else {
                                layer.msg('获取明细失败', {icon: 2, time: 1000});
                            }
                        }, 'GET');
                    }

                    $("#wcabCellInventoryOutBtnAddDetail").click(addTableTr);
                    if(data==undefined){
                        addTableTr();
                    }else{
                        getLoadDetail();
                        $(".saveBatchUnloadSimpleBtn").hide();
                        $("#wcabCellInventoryOutBtnAddDetailDiv").hide();
                    }


                    if(data&&data.eventType=='detail'){
                        $(".saveSimpleBtn").find('*').hide();
                        $(".model-form").find('*').attr('disabled','disabled');
                        $(".model-form input").attr('readonly',true);
                        $(".model-form select").attr('readonly',true);
                    }

                    form.val('wcabCellInventoryOutForm', data);
                    // 表单提交事件
                    form.on('submit(wcabCellInventoryOutFormSubmit)', function (d) {
                        // layer.load(2);
                        // d.field.cabCode=$("#cabId4simpleBatchUnload option:selected").text();
                        var cabCode=$("#cabId4simpleBatchUnload option:selected").data('cabcode');
                        d.field.cabCode=cabCode;
                        var cabId=$("#cabId4simpleBatchUnload option:selected").data('cabid');
                        var detailList=[];
                        var detailMap=new Map();
                        var spaceSkuMap=new Map();
                        $("form select[name='cabLaneId']").each(function(index,item){
                            var id=item.id;
                            // var id2=this.id;
                            var eleNo=id.substring('cabLaneId'.length,id.length);


                            var cabLaneId=$("#cabLaneId"+eleNo).val();
                            var cabLaneCode=$("#cabLaneId"+eleNo+" option:selected").data('spacecode');
                            var quantity=$("#quantity"+eleNo).val();
                            var weight=$("#weight"+eleNo).val();
                            var remark=$("#remark"+eleNo).val();

                            var currentstock=$("#cabLaneId"+eleNo+" option:selected").data('currentstock')
                            var currentWeight=$("#cabLaneId"+eleNo+" option:selected").data('currentweight')
                            var skuId=$("#cabLaneId"+eleNo+" option:selected").data('skuid')
                            var skuCode=$("#cabLaneId"+eleNo+" option:selected").data('skucode')
                            detailList.push({skuCode:skuCode,skuId:skuId,spaceId:cabLaneId,spaceCode:cabLaneCode,quantity:quantity,cabId:cabId,cabCode:cabCode,weight:weight,remark:remark})

                            var val2=spaceSkuMap.get(cabLaneCode);
                            if(val2){
                                val2.quantity+=parseInt(quantity);
                                val2.weight+=parseFloat(weight);
                                spaceSkuMap.set(cabLaneCode,val2);
                            }else{
                                spaceSkuMap.set(cabLaneCode,{cabLaneCode:cabLaneCode,currentstock:parseInt(currentstock),quantity:parseInt(quantity),currentWeight:parseFloat(currentWeight),weight:parseFloat(weight)});
                            }

                        })
                        if(detailList.length==0){
                            layer.msg('请增加下货明细', {icon: 6, time: 2000});
                            return false;
                        }

                        var keys2=[...spaceSkuMap.keys()]
                        var quantityObj
                        keys2.forEach(item=>{
                            var val=spaceSkuMap.get(item);
                            if(val.quantity>val.currentstock||val.weight>val.currentWeight){
                                quantityObj=val;
                            }
                        })
                        if(quantityObj){
                            layer.msg('['+quantityObj.cabLaneCode+']下货数量['+quantityObj.quantity+']重量['+quantityObj.weight+']不能大于当前货道库存数量['+quantityObj.currentstock+']重量['+quantityObj.currentWeight+']', {icon: 6, time: 6000});
                            return false;
                        }



                        d.field.detailList=detailList;
                        // d.field.spaceCode=$("#spaceId4simpleUnload option:selected").text();
                        // d.field.skuCode=$("#spaceId4simpleUnload option:selected").data('skucode');
                        d.field.type='selfBatchUnloadSimple';
                        admin.req(data ? 'enterprisecab/wcabinet/admin/wcabCellLoad/update' : 'enterprisecab/wcabinet/admin/wcabCellInventoryInoutDetail/inventoryOut', JSON.stringify(d.field), function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                                table.reload('wcabCellInventoryOutTable');
                                layer.closeAll('page');
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, data ? 'PUT' : 'POST',true,'application/json; charset=utf-8');
                        return false;
                    });
                }
            });
        }

        function getReceiveData(data){
            var insTb = table.render({
                elem: '#inoutTable',
                url: config.base + 'enterprisecab/wcabinet/admin/wcabCellInventoryInout/list?id='+data.id,
                    // +'&skuCode4Detail='+data.skuCode,
                page: false,
                cellMinWidth: 100,
                cols: [[
                    {type: 'numbers'}

                    ,{field: 'code', sort: true, title: '领用订单编号'}
                    ,{field: 'cabCode', sort: true, title: '柜子编号'}
                    ,{field: 'spaceCode', sort: true, title: '货位编号'}
                    ,{field: 'skuName', sort: true, title: '物料名称'}
                    ,{field: 'skuCode', sort: true, title: '物料编号'}
                    ,{field: 'skuSpecOld', sort: true, title: '规格编号'}
                    // ,{field: 'deviceCode', sort: true, title: '机台'}
                    ,{field: 'weight', sort: true, title: '重量',templet:function (d) {
                            if(d.weight<0){
                                return d.weight*-1;
                            }
                            return d.weight;
                        }}
                    ,{field: 'weightUnitDesc', sort: true, title: '重量单位'}
                    ,{field: 'quantity', sort: true, title: '数量',templet:function (d) {
                            if(d.quantity<0){
                                return d.quantity*-1;
                            }
                            return d.quantity;
                        }}
                    ,{field: 'quantityUnitDesc', sort: true, title: '数量单位'}
                    ,{field: 'creatorName', sort: true, title: '领取人'}
                    ,{field: 'createTime', sort: true, title: '领取时间'}

                    // ,{field: 'no', sort: true, title: 'no'}
                    // ,{field: 'day', sort: true, title: 'day'}
                    // ,{field: 'operationTypeDesc', sort: true, title: '操作类型'}
                    // ,{field: 'businessTypeDesc', sort: true, title: '业务类型'}
                    // ,{field: 'statusDesc', sort: true, title: '状态'}
                    // ,{field: 'checkTime', sort: true, title: '盘验时间'}
                    // ,{field: 'checkUserId', sort: true, title: '盘验人id'}
                    // ,{field: 'checkUserName', sort: true, title: '盘验人'}
                    // ,{field: 'notifyTime', sort: true, title: '通知时间'}
                    // ,{field: 'notifyUserId', sort: true, title: '通知人'}
                    // ,{field: 'notifyUserName', sort: true, title: '通知人'}
                    // ,{field: 'takeUserId', sort: true, title: '回收人id'}
                    // ,{field: 'takeUserName', sort: true, title: '回收人'}
                    // ,{field: 'takeTime', sort: true, title: '回收时间'}
                    // ,{field: 'inoutId', sort: true, title: '暂存柜存刀id'}
                    // ,{field: 'cabId', sort: true, title: '柜子id'}
                    // ,{field: 'skuId', sort: true, title: 'sku id'}
                    // ,{field: 'companyId', sort: true, title: '企业id'}
                    // ,{field: 'spaceId', sort: true, title: '货道id'}
                    // ,{field: 'operationTypeDesc', sort: true, title: '操作类型'}
                    // ,{field: 'businessTypeDesc', sort: true, title: '业务类型'}
                    // ,{field: 'quantityCurrent', sort: true, title: '当前库存'}
                    // ,{field: 'quantityAfter', sort: true, title: '变动后库存'}

                    // ,{align: 'center', toolbar: '#wcabCellInventoryOutTableBar', title: '操作', width: 200}
                ]],
                done: function (res, curr, count) {
                    //移除按钮
                    var menuButton = config.getMenuButton(location.hash);
                    if(menuButton.indexOf("搜索") == -1){
                        $('.layui-form.toolbar').remove();
                    }
                    if(menuButton.indexOf("修改") == -1){
                        $("[lay-event='edit']").remove();
                    }
                    if(menuButton.indexOf("删除") == -1){
                        $("[lay-event='del']").remove();
                    }
                }
            });
        }

        function getReceiveDetail(data){
            var insTb = table.render({
                elem: '#inoutDetailTable',
                // url: config.base + 'enterprisecab/wcabinet/admin/wcabCellInventoryOutDetail/list?inoutId='+data.id+'&skuCode4detail='+data.skuCode,
                url: config.base + 'enterprisecab/wcabinet/admin/wcabCellInventoryInoutDetail/list?inoutId='+data.id,
                page: true,
                cellMinWidth: 100,
                cols: [[
                    {type: 'numbers'}


                    ,{field: 'skuPic', sort: true, title: '物料图片',templet:function (d) {
                            if(d.skuPic){
                                return '<img src="'+ d.skuPic +'" style="height: 20px;"/>';
                            }
                            return '';
                        }}
                    ,{field: 'skuCode', sort: true, title: '物料编号'}
                    ,{field: 'skuName', sort: true, title: '物料名称'}
                    ,{field: 'skuSpec', sort: true, title: '规格'}
                    ,{field: 'skuSpecOld', sort: true, title: '规格编号'}
                    ,{field: 'productBrandName', sort: true, title: '品牌'}
                    ,{field: 'cabCode', sort: true, title: '柜子'}
                    ,{field: 'spaceCode', sort: true, title: '货道'}
                    ,{field: 'weight', sort: true, title: '重量',templet:function (d) {
                            if(d.weight<0){
                                return d.weight*-1;
                            }
                            return d.weight;
                        }}
                    ,{field: 'weightUnitDesc', sort: true, title: '重量单位'}
                    ,{field: 'quantity', sort: true, title: '数量',templet:function (d) {
                            if(d.quantity<0){
                                return d.quantity*-1;
                            }
                            return d.quantity;
                        }}
                    ,{field: 'quantityUnitDesc', sort: true, title: '数量单位'}


                ]],
                done: function (res, curr, count) {
                    //移除按钮
                    var menuButton = config.getMenuButton(location.hash);
                    if(menuButton.indexOf("搜索") == -1){
                        $('.layui-form.toolbar').remove();
                    }
                    if(menuButton.indexOf("修改") == -1){
                        $("[lay-event='edit']").remove();
                    }
                    if(menuButton.indexOf("删除") == -1){
                        $("[lay-event='del']").remove();
                    }
                }
            });
        }

        function showDetailModel(data){
            admin.open({
                type: 1,
                area: '1680px',
                offset: '65px',
                title: '详情',
                content: $('#detailTable').html(),
                success: function () {
                    getReceiveData(data)
                    getReceiveDetail(data);
                }
            })
        }

        // 显示编辑弹窗
        function showEditModel(data) {
            admin.open({
                type: 1,
                area: '880px',
                offset: '65px',
                title: data ? '修改暂存柜存刀/取刀;存/取报修/回收刀' : '添加暂存柜存刀/取刀;存/取报修/回收刀',
                content: $('#storageInventoryInoutForm').html(),
                success: function () {
                    if (data){
                        var option = $("form select[name='operationType']").find("option");
                        layui.each(option, function(index, item){
                            if(data.operationType  == item.text){
                                data.operationType = item.value;
                            }
                        });
                    }

                    if (data){
                        var option = $("form select[name='businessType']").find("option");
                        layui.each(option, function(index, item){
                            if(data.businessType  == item.text){
                                data.businessType = item.value;
                            }
                        });
                    }

                    if (data){
                        var option = $("form select[name='status']").find("option");
                        layui.each(option, function(index, item){
                            if(data.status  == item.text){
                                data.status = item.value;
                            }
                        });
                    }

                    form.val('storageInventoryInoutForm', data);
                    // 表单提交事件
                    form.on('submit(storageInventoryInoutFormSubmit)', function (d) {
                        layer.load(2);
                        admin.req(data ? 'enterprisecab/cabinet/admin/storageInventoryInout/update' : 'enterprisecab/cabinet/admin/storageInventoryInout/add', d.field, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                                table.reload('wcabCellInventoryOutTable');
                                layer.closeAll('page');
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, data ? 'PUT' : 'POST');
                        return false;
                    });
                }
            });
        }

        // 删除
        function doDelete(obj) {
            layer.confirm('确定要删除吗？', {
                offset: '65px',
                skin: 'layui-layer-admin'
            }, function (i) {
                layer.close(i);
                layer.load(2);
                admin.req('enterprisecab/cabinet/admin/storageInventoryInout/' + obj.data.id, {}, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        obj.del();
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'DELETE');
            });
        }

        //时间范围
        laydate.render({
            elem: '#pTime',
            type: 'date',
            range: true,
            done: function (value, date, endDate) {
                if(value){
                    let dateValue = value.split(" - ");
                    $("#startTime").val(dateValue[0]+" 00:00:00");
                    $("#endTime").val(dateValue[1]+" 23:59:59");
                }else {
                    $("#startTime").val("");
                    $("#endTime").val("");
                }
            }
        });

        // 导出领用订单
        /*$('#cellInventoryOutExport').click(function () {
            var sTime = $('#startTime').val();
            var eTime = $('#endTime').val();

            if (sTime == "" && eTime == ""){
                layer.msg('请先选择领取时间！')
            } else {

                location.href = config.base + 'enterprisecab/wcabinet/admin/wcabCellInventoryOut/export?startCreateTime='+sTime+'&endCreateTime='+eTime;
            }
        });*/
        $('#cellInventoryOutExport').click(function () {
            layer.load(2);
            let d = {page: 1, limit: 9999999}, t = layui.$('#exportFrom [name]').serializeArray();
            layui.$.each(t, function () {
                d[this.name] = this.value;
            });

            admin.req('enterprisecab/wcabinet/admin/wcabCellInventoryOut/list', d, res => {
                layer.closeAll('loading');
                if (res.code === 200) {
                    table.exportFile(insTb.config.id, res.data, 'xls', '领新订单列表');
                } else {
                    layer.msg('导出失败', {icon: 2})
                }
            });

        });

    });
</script>